<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>OpenFilePlugin</title>
<meta http-equiv="Content-Type" Content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="../../styles/styles.css">
<script language="javascript" src='../links.js' type="text/javascript"></script>
</head>
<body>
<h1>OpenFilePlugin</h1>
<div class=navbar>
<a href="../index.html">main</a> |
<a href="index.html">exported functions</a>
</div>


<div class=shortdescr>
The <dfn>OpenFilePlugin</dfn> function is called to open a plugin
which emulates a file system based on a file
passed to this function (an archive for example).</div>


<pre class=syntax>
HANDLE WINAPI OpenFilePlugin(
  char *Name,
  const unsigned char *Data,
  int DataSize
);</pre>

<h3>Parameters</h3>
<div class=descr>

    <div class=dfn>Name</div>
    <div class=dfndescr>Points to the full name of the file (including the path).
      This pointer is valid only until return, so if the plugin will process this file,
      it should copy this name to an internal variable.<br>

      The <dfn>OpenFilePlugin</dfn> function is also called when the user is going to create a new
      file (when Shift-F1 is pressed). In that case Name is NULL and other parameters are
      undefined. If a plugin does not support creating new files, it must return
      INVALID_HANDLE_VALUE, otherwise it must return the handle of a new plugin instance that must
      be ready to process <a href="getopenplugininfo.html">GetOpenPluginInfo</a> and
      <a href="putfiles.html">PutFiles</a> functions. If <em>Name</em> is NULL, the plugin
      needs to request <em>Name</em> from the user in the <a href="putfiles.html">PutFiles</a>
      function.</div>
    <div class=dfn>Data</div>
    <div class=dfndescr>Points to data from the beginning of the file. It can be used to detect
      file type. The plugin must not change this data.</div>
    <div class=dfn>DataSize</div>
    <div class=dfndescr>Size of the passed file data. Currently it can be from 0 to 128Kb,
      depending on file size, but you should be ready to process any other value.</div>

</div>

<p><h3>Return value</h3>
<ul>
  <li>If the plugin will process the passed file, the return value must be new plugin handle.</li>
  <li>If this file type is not supported, the return value must be INVALID_HANDLE_VALUE.</li>
  <li>If operation is interrupted by the user, the value -2 (cast to the <strong>HANDLE</strong>
    type) should be returned.</li>
</ul>

<h3>Remarks</h3>
<div class=descr>
<ol>
<li>When &lt;Enter&gt; is pressed on a selected file, FAR queries all plugins that export this
function. The plugins are queried in alphabetic order (sorted by the DLL name). When a plugin
returns a value different from INVALID_HANDLE_VALUE, FAR stops querying other plugins.
<li>The size of data read from the file can be configured - TechInfo #63:
<pre class=code>[HKEY_CURRENT_USER\Software\Far\System]
"PluginMaxReadData":REG_DWORD
The key "System/PluginMaxReadData" of DWORD type allows to set the
maximum size of the data read from a file after an attempt to enter
it from the panels (Enter or Ctrl-PgDn) was made. The data read will
be passed to plugins to determine which plugin supports a file of this
type.
Can be any value in the range of 0x1000 to 0x80000.
The default value is 0x20000.</pre>
</ol>
</div>

</body>
</html>